package com.ruoyi.web.core.config;

import com.lzhpo.chatgpt.OpenAiKey;
import com.lzhpo.chatgpt.OpenAiKeyProvider;
import com.ruoyi.web.controller.chat.util.ChangeDTO;
import org.apache.commons.compress.utils.Lists;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * TODO
 *
 * @author chenchuan2
 * @date 2023-05-24 11:45:35
 */
@Component
public class HfOpenAiKeyProvider implements OpenAiKeyProvider {

    private static List<OpenAiKey> GPT_3_5 = Lists.newArrayList();
    private static List<OpenAiKey> GPT_4 = Lists.newArrayList();

    static {

        OpenAiKey o2 = OpenAiKey.builder().key("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").weight(1.0).enabled(true).build();
        GPT_3_5.add(o2);


        OpenAiKey o3 = OpenAiKey.builder().key("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").weight(1.0).enabled(true).build();
        GPT_3_5.add(o3);

        OpenAiKey o5 = OpenAiKey.builder().key("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").weight(1.0).enabled(true).build();
        GPT_3_5.add(o5);


//
//        OpenAiKey o3 = OpenAiKey.builder().key("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").weight(1.0).enabled(true).build();
//        GPT_3_5.add(o3);



//        OpenAiKey o3 = OpenAiKey.builder().key("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").weight(1.0).enabled(true).build();
//        GPT_3_5.add(o3);



//        OpenAiKey o1 = OpenAiKey.builder().key("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").weight(1.0).enabled(true).build();
//        GPT_3_5.add(o1);
//
//        OpenAiKey o2 = OpenAiKey.builder().key("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").weight(1.0).enabled(true).build();
//        GPT_3_5.add(o2);

//        OpenAiKey o3 = OpenAiKey.builder().key("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").weight(1.0).enabled(true).build();
//        GPT_3_5.add(o3);
//
//        OpenAiKey o4 = OpenAiKey.builder().key("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").weight(1.0).enabled(true).build();
//        GPT_3_5.add(o4);

//
//        OpenAiKey a1 = OpenAiKey.builder().key("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").weight(1.0).enabled(true).build();
//        GPT_4.add(a1);

//        OpenAiKey o4 = OpenAiKey.builder().key("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").weight(1.0).enabled(true).build();
//        GPT_4.add(o4);
    }

    @Override
    public List<OpenAiKey> get() {
        ChangeDTO model = HfThreadLocal.getModel();
        if (null == model || !model.getChangeModelName().startsWith(ChatModel.GPT_4.getModelShortName())) {
            return GPT_3_5;
        } else {
            return GPT_4;
        }
    }
}
